<html id="ajaxEcho" xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui">
	<h:body>
	<ui:composition template="/template/template.xhtml">
	
		<h1 class="ui-widget" ><h:outputText value="#{msg['titulo.gestaoProfissional']}" /></h1>

		<ui:define name="corpo">
		<h:form id="formPermissoes">

			<p:growl />
			<p:dataTable id="tabelaPermissoes" var="permissao" value="#{permissaoController.permissoes}"
				rows="10" paginator="true" 
				paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
				currentPageReportTemplate="[ Exibindo de {startRecord} a {endRecord} no total de {totalRecords}  
                                                           - Página: {currentPage}/{totalPages} ]" 
				rowsPerPageTemplate="5,10,15">
				
				<f:facet name="header">
			       <h:outputText value="#{msg['permissoes.listar.permissoesCadastradas']}" />
			 
			        <p:commandButton id="toggler" type="button" value="#{msg['titulo.colunas']}" style="float:right" icon="ui-icon-calculator" />
			        <p:columnToggler datasource="tabelaPermissoes" trigger="toggler" />
			    </f:facet>
				
				<p:column headerText="#{msg['permissao.nome']}" sortBy="#{permissao.nome}" width="200">
					<h:outputText value="#{permissao.nome}" />
				</p:column>

				<p:column headerText="#{msg['permissao.descricao']}" sortBy="#{permissao.descricao}" >
					<h:outputText value="#{permissao.descricao}" />
				</p:column>
				
				<p:column headerText="#{msg['permissao.listar.acao']}" width="72" exportable="false">
					<p:commandLink action="#{permissaoController.excluir(permissao)}" update=":formPermissoes">
						<p:graphicImage url="/img/delete.png" width="24" height="24"/>
						<p:confirm header="Confirmation" message="#{msg['permissao.excluir.confirmacao']}" icon="ui-icon-alert" />
					</p:commandLink>
					<p:confirmDialog global="true" showEffect="fade" hideEffect="explode" >
				        <p:commandButton value="#{msg['botao.sim']}" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
				        <p:commandButton value="#{msg['botao.nao']}" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
				   </p:confirmDialog>
				   <p:commandLink action="/paginas/permissao/alterar">
				   		<p:graphicImage url="/img/edit.png" width="24" height="24"/>
				   		<f:param name="idPermissao" value="#{permissao.id}"/>
					</p:commandLink>
					
					<p:commandLink action="/paginas/permissao/detalhar">
						<p:graphicImage url="/img/find.png" width="24" height="24"/>
				   		<f:param name="idPermissao" value="#{permissao.id}"/>
					</p:commandLink>
				</p:column>

			</p:dataTable>
			<br/>
			<div align="right">
			 <p:commandButton id="adicionar" value="#{msg['permissao.adicionar']}" action="/paginas/permissao/adicionar" ajax="false" icon="ui-icon-plus"/>
			</div>
			
	<h3 class="ui-widget"><h:outputText value="#{msg['titulo.exportarDados']}" /></h3>
    <h:commandLink>
        <p:graphicImage url="/img/excel.png" />
        <p:dataExporter type="xls" target="tabelaPermissoes" fileName="permissoes" pageOnly="true"/>
    </h:commandLink>
 
    <h:commandLink>
        <p:graphicImage url="/img/pdf.png" />
        <p:dataExporter type="pdf" target="tabelaPermissoes" fileName="permissoes" pageOnly="true" />
    </h:commandLink>
 
    <h:commandLink>
        <p:graphicImage url="/img/csv.png" />
        <p:dataExporter type="csv" target="tabelaPermissoes" fileName="permissoes" pageOnly="true" />
    </h:commandLink>
 
    <h:commandLink>
        <p:graphicImage url="/img/xml.png" />
        <p:dataExporter type="xml" target="tabelaPermissoes" fileName="permissoes" pageOnly="true" />
    </h:commandLink>
		</h:form>
		    		</ui:define>
	</ui:composition>
	</h:body>
</html>